
app:registClass("ChessController", "app.chess.controllers.ChessController")

local ChessModel = import(".models.ChessModel")

app:registInst(ChessModel.new())

app:registInst(app:getClass("ChessController").new({type="world", zOrder=SceneZOrder.desktopZOrder}))

local model = app:getInst("ChessModel")

-- 开始星空谜棋
app.session:on("pb_starchess.S2C_StarChessGameInfo", function(msg)
	model:S2C_StarChessGameInfo(msg)
end)

-- 回合开始
app.session:on("pb_starchess.S2C_StarChessRoundStart", function(msg)
	model:S2C_StarChessRoundStart(msg)
end)

-- roll点结果
app.session:on("pb_starchess.S2C_StarChessDiceResult", function(msg)
	model:S2C_StarChessDiceResult(msg)
end)

-- 玩家移动
app.session:on("pb_starchess.S2C_StarChessPlayerMove", function(msg)
	model:S2C_StarChessPlayerMove(msg)
end)

-- 玩家抉择
app.session:on("pb_starchess.S2C_StarChessPlayerSelect", function(msg)
	model:S2C_StarChessPlayerSelect(msg)
end)

-- 玩家事件信息
app.session:on("pb_starchess.S2C_StarChessActionInfo", function(msg)
	model:S2C_StarChessActionInfo(msg)
end)

-- 玩家信息更新（自己局部更新）
app.session:on("pb_starchess.S2C_StarChessOperation", function(msg)
	model:S2C_StarChessOperation(msg)
end)

-- 玩家信息更新（回合结束整体更新）
app.session:on("pb_starchess.S2C_StarChessPlayerUpdate", function(msg)
	model:S2C_StarChessPlayerUpdate(msg)
end)

-- 星空谜棋战斗结果
app.session:on("pb_map.S2C_BattleEnd", function(msg)
	model:S2C_BattleEnd(msg)
end)

-- 星空谜棋结果
app.session:on("pb_starchess.S2C_StarChessResult", function(msg)
	model:S2C_StarChessResult(msg)
end)

-- roll点返回
app.session:on("pb_starchess.S2C_StarChessDice", function(msg)
	-- dump(msg, "S2C_StarChessDice")
	if not msg.ok then
		display.pushToast(msg.error)
	end
end)

-- 行动结束返回
app.session:on("pb_starchess.S2C_StarChessActionOver", function(msg)
	-- dump(msg, "S2C_StarChessActionOver")
	if not msg.ok then
		display.pushToast(msg.error)
	end
end)

-- 抉择返回
app.session:on("pb_starchess.S2C_StarChessSelect", function(msg)
	-- dump(msg, "S2C_StarChessSelect")
	if not msg.ok then
		display.pushToast(msg.error)
	end
end)


